Skip to content

Fix/ephemeral balance undelegation 2.0 #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 13, 2025

Conversation

taco-paco
Copy link
Contributor

@taco-paco taco-paco commented May 8, 2025

⚠️ NOTE: Use notes like this to emphasize something important about the PR.

This could include other PRs this PR is built on top of; API breaking changes; reasons for why the PR is on hold; or anything else you would like to draw attention to.

Status Type ⚠️ Core Change Issue
Ready/Hold Feature/Bug/Tooling/Refactor/Hotfix Yes/No Link

Problem

What problem are you trying to solve?

Solution

How did you solve the problem?

Before & After Screenshots

Insert screenshots of example code output

BEFORE:
[insert screenshot here]

AFTER:
[insert screenshot here]

Other changes (e.g. bug fixes, small refactors)

Deploy Notes

Notes regarding deployment of the contained body of work. These should note any
new dependencies, new scripts, etc.

New scripts:

  • script : script details

New dependencies:

  • dependency : dependency details

Greptile Summary

Here's my concise review of the ephemeral balance undelegation changes:

Adds external undelegation functionality and improves ephemeral balance account management in the delegation program.

  • Added new ExternalUndelegate instruction (discriminator 15) in src/discriminator.rs to handle external undelegation of accounts owned by DLP
  • Modified close_ephemeral_balance.rs to use direct system program transfers instead of close_pda helper, with proper ownership verification
  • Added EphemeralBalance struct (discriminator 104) in src/state/ephemeral_balance.rs as a marker type for temporary balance accounts
  • Added comprehensive tests in test_top_up.rs verifying ownership transfers and account closure during undelegation
  • Improved account discriminator handling by making to_bytes a const function and adding proper initialization checks

The changes appear well-structured and properly integrated with existing functionality, with good test coverage for the new features.

@taco-paco taco-paco requested a review from GabrielePicco May 8, 2025 09:46
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the current approach is not ideal, as the discriminator is only set on delegation (which defeat the idea of using it as a filter to get all escrow accounts), plus the handling of the callback becomes hacky. I prosed in this PR an implementation that it's simpler by removing the discriminator: #78

* fix: remove discriminator

* chore: simplify fix

* fix: delegation record with system program as owner & add tests
@GabrielePicco GabrielePicco self-requested a review May 12, 2025 11:44
@GabrielePicco GabrielePicco merged commit 9570abf into main May 13, 2025
3 checks passed
@GabrielePicco GabrielePicco deleted the fix/ephemeral-balance-undelegation-2.0 branch May 13, 2025 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants